package org.apache.mina.common;

import java.net.SocketAddress;

/**
 * An {@link IoSession} for broadcast transports. (e.g. UDP broadcast or
 * multicast)
 * 
 * 广播通讯协议的IoSession（比如UDP广播或组播）。
 * 
 * <h2>Writing Back to the Broadcasting Server</h2>
 * <p>
 * When you implement a client that receives a broadcast message from a server
 * such as DHCP server, the client might need to send a response message for the
 * broadcast message the server sent. Because the remote address of the session
 * is not the address of the server in case of broadcasting, there should be a
 * way to specify the destination when you write the response message. This
 * interface provides {@link #write(Object, SocketAddress)} method so you can
 * specify the destination.
 * </p>
 * 
 * 写回广播服务
 * 
 * 当你实现了一个从服务端（比如DHCP）接收广播信息的客户端时，该客户端可能需要发送一个回复信息。
 * 因为如果是广播，此会话的远程地址不是该服务的地址，所以在发送回复信息时，必须有一种方法去指定目的地，
 */
public interface BroadcastIoSession extends IoSession {
    /**
     * Writes the specified <tt>message</tt> to the specified
     * <tt>destination</tt>. This operation is asynchronous;
     * {@link IoHandler#messageSent(IoSession, Object)} will be invoked when the
     * message is actually sent to remote peer. You can also wait for the
     * returned {@link WriteFuture} if you want to wait for the message actually
     * written.
     * 
     * @param destination
     *            <tt>null</tt> if you want the message sent to the default
     *            remote address
     */
    WriteFuture write(Object message, SocketAddress destination);
}
